//
//  CommentViewController.swift
//  app4crew
//
//  Created by apple on 16/2/26.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit
import IQKeyboardManager

class CommentViewController: UIViewController,UITextViewDelegate,RatingBarDelegate {
    
    @IBOutlet weak var commentTotal: RatingBar!
    @IBOutlet weak var commentHotel: RatingBar!
    @IBOutlet weak var commentCustoms: RatingBar!
    @IBOutlet weak var commentSupplies: RatingBar!
    
    @IBOutlet weak var commentInput: UITextView!
    
    @IBAction func backbtnclick(sender: AnyObject) {
        self.dismissViewControllerAnimated(true, completion: nil)
    }
    var placeHolderLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        IQKeyboardManager.sharedManager().enable = true
        
        commentTotal.delegate = self
        commentHotel.delegate = self
        commentCustoms.delegate = self
        commentSupplies.delegate = self
        commentTotal.backgroundColor = UIColor.clearColor()
        commentHotel.backgroundColor = UIColor.clearColor()
        commentCustoms.backgroundColor = UIColor.clearColor()
        commentSupplies.backgroundColor = UIColor.clearColor()
        
        placeHolderLabel = UILabel()
        placeHolderLabel.text = "请点击这里输入评论"
        placeHolderLabel.textColor = UIColor.lightGrayColor()
        placeHolderLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleSubheadline)
        commentInput.addSubview(placeHolderLabel)
        commentInput.layer.borderColor = UIColor.grayColor().CGColor
        commentInput.layer.borderWidth = 1
        commentInput.layer.cornerRadius = 6
        commentInput.layer.masksToBounds = true
        
        placeHolderLabel.snp_makeConstraints { (make) -> Void in
            make.center.equalTo(commentInput)
        }
    }
    
    func ratingDidChange(ratingBar: RatingBar, rating: CGFloat) {
        //print(ratingBar.rating)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //MARK: textViewDelegate
    func textViewDidBeginEditing(textView: UITextView) {
        placeHolderLabel.hidden = true
    }
    
    func textViewDidEndEditing(textView: UITextView) {
        placeHolderLabel.hidden = !textView.text.isEmpty
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
